<?php 
	class Category{
		Static public function unlimitedForLevel($cate){
			$arr=array();
			$i=0;
			foreach ($cate as  $v) {
				if($v['pid']==0){
					$v['level']=1;
					$v['html']='';
					$arr[$i]=$v;
					$i++;
				}
				foreach ($cate as  $value) {
					if($v['id']==$value['pid']){
						$value['level']=2;
						$value['html']='----';
						$arr[$i]=$value;
						$i++;
					}
				}
			}
			return $arr;
		}
		Static function getChild($cate,$id){
			$a[]=$id;
			foreach ($cate as $v) {
				if($id==$v['pid'])
					$a[]=$v['id'];
			}
			return $a;
		}
		Static function getCate($cate,$id){
			foreach ($cate as $v) {
				if($id==$v['id'])
					return $v;
			}
			return false;
		}
	}